package service;

import dao.UserDao;
import dao.UserdaoImpl;
import entity.User;
import util.MD5Utils;

/**
 * @author 孙亚梅
 * @version V1.0
 * @Project javase2203
 * @Package service
 * @Description:
 * @Date 2022/5/27 13:36
 */
public class UserServiceImpl  implements  UserService{

private UserDao userDao = new UserdaoImpl();
    @Override
    public User login(String uname, String pwd) {
       User user = userDao.selectUser(uname);
       if (user==null){
           return null;
       }
        //5：判断密码是否正确，密码正确返回true
        String md5PassWord = MD5Utils.md5(pwd);
        System.out.println(md5PassWord);
        if (user.getPassword().equals(md5PassWord)){
            return user;
        }
        //6:其他情况返回false

        return null;
    }
}
